//
//  StatusesTableViewCell.m
//  11217微博状态
//
//  Created by student on 16/3/8.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "StatusesTableViewCell.h"

@implementation StatusesTableViewCell

- (void)awakeFromNib {
    // Initialization code
    //设定UILabel每行文字的最大宽度
    self.contentLabel.preferredMaxLayoutWidth=[UIScreen mainScreen].bounds.size.width-20;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)setStatus:(StatusesModel *)status{
    _status=status;
    self.iconImage.image = [UIImage imageNamed:status.icon];
    self.nameLabel.text = status.name;
    self.contentLabel.text = status.text;
    
    self.vipImage.hidden = !status.vip;
    
    if (status.picture==nil)
    {
        self.pictureImage.hidden=YES;
    }
    else
    {
        self.pictureImage.hidden=NO;
        self.pictureImage.image = [UIImage imageNamed:status.picture];
    }
    
    //强制更新布局
    [self layoutIfNeeded];
    
    if (self.pictureImage.hidden)
    {
        _status.cellHeight=CGRectGetMaxY(self.contentLabel.frame)+10;
    }
    else
    {
        _status.cellHeight=CGRectGetMaxY(self.pictureImage.frame)+10;
    }

}

@end
